笔记: 带实体的 Collection 与 List 集合转换~
//求并集--a和b是自己创建的实体List集合 T实体类 Collection<T> union= CollectionUtils.union(a,b); //Collection转化成List Iterator<T> iterator = union.iterator(); Collection<T> entityList =new ArrayList<>(); while (iterator .hasNext()){ T needEntity= iterator.next(); entityList.add(needEntity); } System.out.println(entityList);
|